package com.ruoyi.web.controller.newTable;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TPyfx;
import com.ruoyi.system.service.ITPyfxService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 培养方向与特色Controller
 * 
 * @author ruoyi
 * @date 2024-12-08
 */
@RestController
@RequestMapping("/system/pyfx")
public class TPyfxController extends BaseController
{
    @Autowired
    private ITPyfxService tPyfxService;

    /**
     * 查询培养方向与特色列表
     */
    @PreAuthorize("@ss.hasPermi('system:pyfx:list')")
    @GetMapping("/list")
    public TableDataInfo list(TPyfx tPyfx)
    {
        startPage();
        List<TPyfx> list = tPyfxService.selectTPyfxList(tPyfx);
        return getDataTable(list);
    }

    /**
     * 导出培养方向与特色列表
     */
    @PreAuthorize("@ss.hasPermi('system:pyfx:export')")
    @Log(title = "培养方向与特色", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TPyfx tPyfx)
    {
        List<TPyfx> list = tPyfxService.selectTPyfxList(tPyfx);
        ExcelUtil<TPyfx> util = new ExcelUtil<TPyfx>(TPyfx.class);
        util.exportExcel(response, list, "培养方向与特色数据");
    }

    /**
     * 获取培养方向与特色详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:pyfx:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tPyfxService.selectTPyfxById(id));
    }

    /**
     * 新增培养方向与特色
     */
    @PreAuthorize("@ss.hasPermi('system:pyfx:add')")
    @Log(title = "培养方向与特色", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TPyfx tPyfx)
    {
        return toAjax(tPyfxService.insertTPyfx(tPyfx));
    }

    /**
     * 修改培养方向与特色
     */
    @PreAuthorize("@ss.hasPermi('system:pyfx:edit')")
    @Log(title = "培养方向与特色", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TPyfx tPyfx)
    {
        return toAjax(tPyfxService.updateTPyfx(tPyfx));
    }

    /**
     * 删除培养方向与特色
     */
    @PreAuthorize("@ss.hasPermi('system:pyfx:remove')")
    @Log(title = "培养方向与特色", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tPyfxService.deleteTPyfxByIds(ids));
    }
}
